﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
                    xmlns:ubcn="clr-namespace:UBCon.Navigation"
                    xmlns:effect="clr-namespace:UBCon.Resources.Effects;assembly=UBCon.Resources"
                    xmlns:skin="clr-namespace:UBCon.Navigation.SkinManagers">

    <BooleanToVisibilityConverter x:Key="BooleanConverter" />

    <!--================================ButtonChrome Template And Style==============================================-->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:ButtonChrome}, ResourceId=ButtonChromeTemplate}"
                     TargetType="{x:Type ubcn:ButtonChrome}">
        <Grid x:Name="PART_Root" Height="{TemplateBinding Height}" >
            <Border   x:Name="PART_DefaultButton" CornerRadius="{TemplateBinding CornerRadius}"
                      Background="{TemplateBinding Background}" 
                      BorderThickness="{TemplateBinding BorderThickness}"
                      BorderBrush="{TemplateBinding BorderBrush}" 
                      Margin="0" />
            <Border x:Name="PART_HoverButton" 
                    Opacity="0" 
                    BorderThickness="{TemplateBinding BorderThickness}"
                    BorderBrush="{TemplateBinding MouseOverBorderBrush}" 
                    Focusable="False" 
                    Margin="0" CornerRadius="{TemplateBinding CornerRadius}"
                    Background="{TemplateBinding MouseOverBackgroundBrush}"/>
            <Border x:Name="PART_PressedButton" 
                    Opacity="0" 
                    BorderThickness="{TemplateBinding BorderThickness}"
                    BorderBrush="{TemplateBinding PressedBorderBrush}" 
                    Focusable="False" 
                    Margin="0" 
                    CornerRadius="{TemplateBinding CornerRadius}"
                    Background="{TemplateBinding PressedBackgroundBrush}"/>
            <ContentPresenter Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" 
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="RenderMouseOver" Value="True" >
                <Setter Property="Opacity" Value="0" TargetName="PART_DefaultButton"/>
                <Setter Property="Opacity" Value="0" TargetName="PART_PressedButton"/>
                <Setter Property="Opacity" Value="1" TargetName="PART_HoverButton" />
            </Trigger>
            <Trigger Property="RenderPressed" Value="True">
                <Setter Property="Opacity" Value="0" TargetName="PART_DefaultButton"/>
                <Setter Property="Opacity" Value="0" TargetName="PART_HoverButton"/>
                <Setter Property="Opacity" Value="1" TargetName="PART_PressedButton"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcn:ButtonChrome}" TargetType="{x:Type ubcn:ButtonChrome}">
        <Setter Property="Background" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedBorderBrush}}" />
        <Setter Property="InnerBorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="MouseOverBorderBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBorderBrush}}" />
        <Setter Property="MouseOverBackgroundBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}"/>
        <Setter Property="PressedBorderBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBorderBrush}}" />
        <Setter Property="PressedBackgroundBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="InnerBorderThickness" Value="0"/>
        <Setter Property="CornerRadius" Value="0"/>
        <Setter Property="InnerBorderCornerRadius" Value="0"/>
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:ButtonChrome}, ResourceId=ButtonChromeTemplate}}"/>
    </Style>

    <!--============================== OutlookBar Template and Style============================== -->
    
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:OutlookBar}, ResourceId=DefaultOutlookBarTemplate}"
                     TargetType="{x:Type ubcn:OutlookBar}">
        <Grid Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" x:Name="itemsRow" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid Width="{Binding Path=PaneWidth, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
                  HorizontalAlignment="Left"
                  x:Name="paneGrid">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Border Width="{TemplateBinding Width}"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=OutlookPaneBackgroundBrush}}"
                        Grid.RowSpan="2"/>
                <Button HorizontalAlignment="Right"
                        Width="20"
                        Height="20"
                        Command="{Binding Path=CollapsExpandCommand, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                        CommandParameter="Collapse"
                        x:Name="collapseButton">
                    <Button.Template>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsPressed}">
                                <Image Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CollapseButtonImage}}"
                                       Height="7"
                                       Width="7"/>
                            </ubcn:ButtonChrome>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
                <Button HorizontalAlignment="Right"
                        Width="20"
                        Height="20"
                        Command="{Binding Path=CollapsExpandCommand, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                        CommandParameter="Expand"
                        Visibility="Collapsed"
                        x:Name="expandButton">
                    <Button.Template>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsPressed}">
                                <Image Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ExpandButtonImage}}"
                                       Height="7"
                                       Width="7"/>
                            </ubcn:ButtonChrome>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
                <ListBox Grid.Row="1"
                         Margin="3"
                         x:Name="PART_NavigationItemsHost"
                         Visibility="Collapsed">
                    <ListBox.Template>
                        <ControlTemplate TargetType="{x:Type ListBox}">
                            <ubcn:VerticalPanel IsItemsHost="True"
                                                Margin="3"/>
                        </ControlTemplate>
                    </ListBox.Template>
                </ListBox>
                <ContentPresenter Grid.Row="1"
                                  Margin="3"
                                  x:Name="PART_InnerContentPresenter"/>
                <Thumb Grid.RowSpan="2"
                       Margin="0,7,0,0"
                       Grid.Column="1"
                       Cursor="ScrollWE"
                       x:Name="PART_OutlookBarThumb">
                    <Thumb.Template>
                        <ControlTemplate>
                            <Grid >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="1" />
                                    <ColumnDefinition Width="7" />
                                </Grid.ColumnDefinitions>
                                <Rectangle Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}"
                                           Width="1"/>
                                <Rectangle Grid.Column="1"
                                           Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"/>
                            </Grid>
                        </ControlTemplate>
                    </Thumb.Template>
                </Thumb>
                
            </Grid>

            <AdornerDecorator Grid.Column="1"
                              Grid.RowSpan="1" x:Name="innerCP">
                <ContentPresenter ContentSource="InnerContent"
                                x:Name="OutlookBar_InnerContentPresenter"/>
            </AdornerDecorator>

            <Border Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=OutlookBarBackgroundBrush}}"
                    Grid.Row="1"
                    Grid.ColumnSpan="2"
                    x:Name="itemsBorder"
                    BorderThickness="0, 1, 1, 0"
                    BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}">
                <Grid x:Name="itemsGrid" 
                      VerticalAlignment="Bottom"
                      Height="{Binding Path=ItemsGridHeight, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" x:Name="row"/>
                    </Grid.RowDefinitions>
                    <Thumb Visibility="Collapsed"
                           x:Name="OutlookBar_upDownResizeThumb"
                           Cursor="SizeNS"
                           VerticalAlignment="Top"
                           Grid.ColumnSpan="2"
                           Height="6"
                           Margin="0,-7, 0, 0">
                        <Thumb.Template>
                            <ControlTemplate TargetType="{x:Type Thumb}">
                                <Rectangle Height="6"
                                           Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"/>
                            </ControlTemplate>
                        </Thumb.Template>
                    </Thumb>
                    <ubcn:SwapPanel Orientation="Horizontal" 
                                    IsItemsHost="True"
                                    Margin="5, 0, 0, 0"
                                    x:Name="itemsHost"
                                    Grid.RowSpan="2"
                                    ItemsDraggable="True"
                                    />
                    <ubcn:DropDownMenu Grid.Column="1"
                                        Margin="10, 0, 0, 0"
                                        x:Name="PART_Menu"
                                        Grid.RowSpan="2"
                                        Grid.Row="0"
                                        VerticalAlignment="Center"
                                        Height="30"
                                        Width="30"
                                       ItemsSource="{Binding Path=MenuItems, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode= OneWay}">
                        <ubcn:DropDownMenu.Template>
                            <ControlTemplate TargetType="{x:Type ubcn:DropDownMenu}">
                                <Grid>
                                    <ToggleButton IsChecked="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
                                                  ClickMode="Release">
                                        <ToggleButton.Template>
                                            <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}"
                                                                   RenderPressed="{TemplateBinding IsChecked}"
                                                                   HorizontalContentAlignment="Center"
                                                                   x:Name="rootButton">
                                                    <Grid Margin="{TemplateBinding Padding}">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="8" />
                                                            <ColumnDefinition Width="8" />
                                                            <ColumnDefinition Width="8"/>
                                                        </Grid.ColumnDefinitions>
                                                        <Ellipse Fill="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}"
                                                                Height="4"
                                                                Width="4"
                                                                Opacity="0.7"
                                                                HorizontalAlignment="Center"
                                                                VerticalAlignment="Center"
                                                                 x:Name="firstEllipse"/>
                                                        <Ellipse Fill="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}"
                                                                 Height="4"
                                                                 Width="4"
                                                                 Opacity="0.7"
                                                                 Grid.Column="1"
                                                                 HorizontalAlignment="Center"
                                                                 VerticalAlignment="Center"
                                                                 x:Name="secondEllipse"/>
                                                        <Ellipse Fill="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}"
                                                                 Height="4"
                                                                 Width="4"
                                                                 Opacity="0.7"
                                                                 Grid.Column="2"
                                                                 HorizontalAlignment="Center"
                                                                 VerticalAlignment="Center"
                                                                 x:Name="thirdEllipse"/>
                                                    </Grid>
                                                </ubcn:ButtonChrome>
                                                <ControlTemplate.Triggers>
                                                    <MultiDataTrigger>
                                                        <MultiDataTrigger.Conditions>
                                                            <Condition Binding="{Binding Path=IsMinimized, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcn:OutlookBar}}}" Value="False"/>
                                                            <Condition Binding="{Binding Path=IsCompact, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcn:OutlookBar}}}" Value="True"/>
                                                            <Condition Binding="{Binding Path=HasHorizontallHiddenItems, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcn:OutlookBar}}}" Value="True"/>
                                                        </MultiDataTrigger.Conditions>
                                                        <MultiDataTrigger.Setters>
                                                            <Setter Property="Fill" 
                                                                    Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" 
                                                                    TargetName="firstEllipse"/>
                                                            <Setter Property="Fill" 
                                                                    Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" 
                                                                    TargetName="secondEllipse"/>
                                                            <Setter Property="Fill" 
                                                                    Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" 
                                                                    TargetName="thirdEllipse"/>
                                                        </MultiDataTrigger.Setters>
                                                    </MultiDataTrigger>
                                                    <MultiDataTrigger>
                                                        <MultiDataTrigger.Conditions>
                                                            <Condition Binding="{Binding Path=IsMinimized, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcn:OutlookBar}}}" Value="True"/>
                                                            <Condition Binding="{Binding Path=IsCompact, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcn:OutlookBar}}}" Value="True"/>
                                                            <Condition Binding="{Binding Path=HasVerticalHiddenItems, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcn:OutlookBar}}}" Value="True"/>
                                                        </MultiDataTrigger.Conditions>
                                                        <MultiDataTrigger.Setters>
                                                            <Setter Property="Fill" 
                                                                    Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" 
                                                                    TargetName="firstEllipse"/>
                                                            <Setter Property="Fill" 
                                                                    Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" 
                                                                    TargetName="secondEllipse"/>
                                                            <Setter Property="Fill" 
                                                                    Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" 
                                                                    TargetName="thirdEllipse"/>
                                                            <Setter Property="Background" 
                                                                    Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=OutlookBarBackgroundBrush}}" 
                                                                    TargetName="rootButton"/>
                                                        </MultiDataTrigger.Setters>
                                                    </MultiDataTrigger>

                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </ToggleButton.Template>
                                    </ToggleButton>
                                    <Popup AllowsTransparency="True"
                                           PopupAnimation="None"
                                            Placement="{Binding Path=DropDownPlacement, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay, NotifyOnSourceUpdated=True}"
                                            PlacementTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay, NotifyOnSourceUpdated=True}"
                                            IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
                                            StaysOpen="False"
                                            x:Name="PART_DropDownMenuPopup">
                                        <Border Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                                                BorderThickness="1"
                                                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownBorderBrush}}"
                                                Margin="7">
                                            <Border.RenderTransform>
                                                <TranslateTransform />
                                            </Border.RenderTransform>
                                            <Grid VerticalAlignment="Top"
                                                  x:Name="PART_RibbonDropDownMenuResize"
                                                  MinHeight="32.0"
                                                  MinWidth="{TemplateBinding MinDropDownWidth}">
                                                <Grid.RowDefinitions>
                                                    <RowDefinition />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>
                                                <Border  Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                                                          Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownShadowEffect}}"
                                                          Grid.RowSpan="2"/>
                                                <StackPanel IsItemsHost="True"
                                                            KeyboardNavigation.DirectionalNavigation="Cycle"
                                                            x:Name="PART_DropDownMenuItemsHost"
                                                            Focusable="True"
                                                            FocusVisualStyle="{x:Null}"
                                                            Margin="1"/>
                                            </Grid>
                                        </Border>
                                    </Popup>
                                </Grid>

                            </ControlTemplate>
                        </ubcn:DropDownMenu.Template>
                    </ubcn:DropDownMenu>

                </Grid>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMinimized" Value="False" />
                    <Condition Property="IsCompact" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Height" Value="40" TargetName="itemsGrid"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMinimized" Value="True" />
                    <Condition Property="IsCompact" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Orientation" Value="Vertical" TargetName="itemsHost"/>
                    <Setter Property="VerticalAlignment" Value="Bottom" TargetName="itemsGrid"/>
                    <Setter Property="Visibility" Value="Visible" TargetName="OutlookBar_upDownResizeThumb"/>
                    <Setter Property="Margin" Value="5,10,0,0" TargetName="itemsHost"/>
                    <Setter Property="Margin" Value="6,0,0,0" TargetName="PART_Menu"/>
                    <Setter Property="Grid.Column" Value="0" TargetName="itemsHost"/>
                    <Setter Property="Grid.Column" Value="0" TargetName="PART_Menu"/>
                    <Setter Property="Grid.ColumnSpan" Value="2" TargetName="itemsHost"/>
                    <Setter Property="Grid.ColumnSpan" Value="2" TargetName="PART_Menu"/>
                    <Setter Property="Grid.RowSpan" Value="1" TargetName="itemsHost"/>
                    <Setter Property="Grid.RowSpan" Value="1" TargetName="PART_Menu"/>
                    <Setter Property="Grid.Row" Value="0" TargetName="itemsHost"/>
                    <Setter Property="Grid.Row" Value="1" TargetName="PART_Menu"/>
                    <Setter Property="Height" Value="Auto" TargetName="row"/>
                    <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=OutlookPaneBackgroundBrush}}" TargetName="itemsBorder"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsMinimized" Value="True">
                <Setter Property="Visibility" Value="Collapsed" TargetName="collapseButton"/>
                <Setter Property="Visibility" Value="Visible" TargetName="expandButton"/>
                <Setter Property="Visibility" Value="Visible" TargetName="PART_NavigationItemsHost"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="PART_InnerContentPresenter"/>
            </Trigger>
            <Trigger Property="IsMinimized" Value="False">
                <Setter Property="Visibility" Value="Visible" TargetName="collapseButton"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="expandButton"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="PART_NavigationItemsHost"/>
            </Trigger>
            <Trigger Property="IsCompact" Value="True">
                <Setter Property="Grid.ColumnSpan" Value="1" TargetName="itemsBorder"/>
                <Setter Property="Grid.RowSpan" Value="2" TargetName="innerCP"/>
                <Setter Property="Margin" Value="0, 0, 8, 0" TargetName="itemsBorder"/>
                <Setter Property="HorizontalAlignment" Value="Left" TargetName="itemsBorder"/>
                <Setter Property="Width" Value="{Binding Path=ItemsPaneWidth, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}" 
                        TargetName="itemsBorder"/>
            </Trigger>
            <Trigger Property="IsCompact" Value="False">
                <Setter Property="MinHeight" Value="50" TargetName="itemsGrid"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcn:OutlookBar}" TargetType="{x:Type ubcn:OutlookBar}">
        <Setter Property="PaneWidth" Value="300"/>
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:OutlookBar}, ResourceId=DefaultOutlookBarTemplate}}"/>
    </Style>

    <!--============================== OutlookBarItem Template and Style============================== -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:OutlookBarItem}, ResourceId=DefaultOutlookBarItemTemplate}"
                     TargetType="{x:Type ubcn:OutlookBarItem}">
        <Grid>
            <TextBlock Text="{TemplateBinding Title}"
                   FontSize="25"
                   VerticalAlignment="Center"
                   x:Name="PART_RootControl"
                   FontWeight="Light"
                   RenderTransformOrigin="0.5, 0.5"/>
            <Popup AllowsTransparency="True"
                   Placement="Top"
                   PlacementTarget="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                   StaysOpen="True"
                   PopupAnimation="None"
                   HorizontalOffset="{Binding Path=HorizontalOffset, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                   VerticalOffset="{Binding Path=VerticalOffset, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                   x:Name="PART_OutlookBarItemPopup">
                <Grid Height="{TemplateBinding DropDownHeight}"
                      Width="{TemplateBinding DropDownWidth}"
                      Margin="7">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="15" />
                    </Grid.RowDefinitions>
                    <Border  Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                             Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownShadowEffect}}"/>
                    <Border BorderBrush="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" 
                            BorderThickness="1"
                            Background="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"/>
                    <Image Grid.Row="1" 
                           Stretch="Fill"
                           Width="23"
                           Height="13"
                           VerticalAlignment="Top"
                           Margin="0,-2, 0, 0"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownArrowImage}}"
                           x:Name="PART_ItemDownImage"
                           HorizontalAlignment="Center"/>
                    <Rectangle Grid.Row="0" 
                               VerticalAlignment="Bottom" 
                               Height="2" 
                               Stroke="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" 
                               Fill="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" 
                               Margin="1,0, 1, 1"/>
                    <ContentPresenter Grid.Row="0" 
                                      Margin="2" 
                                      Content="{TemplateBinding DropDownContent}"/>
                </Grid>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <!--<Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}"
                        TargetName="PART_RootControl"/>
            </Trigger>-->
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}"
                        TargetName="PART_RootControl"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:OutlookBarItem}, ResourceId=CompactOutlookBarItemTemplate}"
                     TargetType="{x:Type ubcn:OutlookBarItem}">
        <Grid>
            <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}"
                               RenderPressed="{TemplateBinding IsSelected}"
                               x:Name="PART_RootControl"
                               Width="{TemplateBinding Width}"
                               Height="{TemplateBinding Height}">
                <Image HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Height="20"
                       Width="20"
                       Source="{TemplateBinding Image}"/>
            </ubcn:ButtonChrome>
            <Popup AllowsTransparency="True"
                   Placement="{TemplateBinding Placement}"
                   PlacementTarget="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                   StaysOpen="True"
                   PopupAnimation="None"
                   HorizontalOffset="{Binding Path=HorizontalOffset, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                   VerticalOffset="{Binding Path=VerticalOffset, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}"
                   x:Name="PART_OutlookBarItemPopup">
                <Grid Height="{TemplateBinding DropDownHeight}"
                      Width="{TemplateBinding DropDownWidth}"
                      Margin="7">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0" x:Name="col" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="15" x:Name="row"/>
                    </Grid.RowDefinitions>
                    <Border  Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                             Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownShadowEffect}}"
                             Grid.Column="1"/>
                    <Border BorderBrush="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" 
                            BorderThickness="1"
                            Background="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                            Grid.Column="1"/>
                    <Image Grid.Row="1" 
                           Stretch="Fill"
                           Width="23"
                           Height="13"
                           VerticalAlignment="Top"
                           Margin="0,-2, 0, 0"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownArrowImage}}"
                           x:Name="PART_ItemDownImage"
                           HorizontalAlignment="Center"
                           Grid.Column="1"/>
                    <Image Grid.Row="0" 
                           Stretch="Fill"
                           Width="13"
                           Height="23"
                           VerticalAlignment="Bottom"
                           Margin="0,0,-2,5"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownLeftArrowImage}}"
                           x:Name="PART_ItemLeftImage"
                           HorizontalAlignment="Right"
                           Grid.Column="0"
                           Visibility="Collapsed"
                           />
                    <Rectangle Grid.Row="0" 
                               Grid.Column="1"
                               VerticalAlignment="Bottom" 
                               Height="2" 
                               Stroke="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" 
                               Fill="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" 
                               Margin="1,0, 1, 1"
                               x:Name="bottomRect"/>
                    <Rectangle Grid.Row="0" 
                               Grid.Column="1"
                               Width="2" 
                               Stroke="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" 
                               Fill="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" 
                               Margin="1"
                               HorizontalAlignment="Left"
                               x:Name="leftRectangle"
                               Visibility="Collapsed"/>
                    <ContentPresenter Grid.Row="0" 
                                      Margin="2" 
                                      Content="{TemplateBinding DropDownContent}"
                                      Grid.Column="1"/>
                </Grid>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=ParentOutlook.IsCompact, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True"/>
                    <Condition Binding="{Binding Path=ParentOutlook.IsMinimized, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True"/>
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter Property="Height" Value="0" TargetName="row"/>
                    <Setter Property="Width" Value="15" TargetName="col"/>
                    <Setter Property="Visibility" Value="Collapsed" TargetName="PART_ItemDownImage"/>
                    <Setter Property="Visibility" Value="Collapsed" TargetName="bottomRect"/>
                    <Setter Property="Visibility" Value="Visible" TargetName="PART_ItemLeftImage"/>
                    <Setter Property="Visibility" Value="Visible" TargetName="leftRectangle"/>
                    <Setter Property="Placement" Value="Right"/>
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>            
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcn:OutlookBarItem}" TargetType="{x:Type ubcn:OutlookBarItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=ParentOutlook.IsCompact, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="False">
                <Setter Property="Margin" Value="15, 0, 0, 0"/>
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:OutlookBarItem}, ResourceId=DefaultOutlookBarItemTemplate}}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=ParentOutlook.IsCompact, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True">
                <Setter Property="Width" Value="30"/>
                <Setter Property="Height" Value="30"/>
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:OutlookBarItem}, ResourceId=CompactOutlookBarItemTemplate}}"/>
            </DataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=ParentOutlook.IsCompact, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True"/>
                    <Condition Binding="{Binding Path=ParentOutlook.IsMinimized, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True"/>
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter Property="Margin" Value="3,0"/>
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=ParentOutlook.IsCompact, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True"/>
                    <Condition Binding="{Binding Path=ParentOutlook.IsMinimized, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="False"/>
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter Property="Margin" Value="15, 0, 0, 0"/>
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>
        </Style.Triggers>
    </Style>

    <!--================================NavigationItem Template And Style==============================================-->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:NavigationItem}, ResourceId=DefaultNavigationitemTemplate}"
                     TargetType="{x:Type ubcn:NavigationItem}">
        <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsSelected}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           BorderThickness="{TemplateBinding BorderThickness}"
                           Background="{TemplateBinding Background}"
                           PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=OutlookBarBackgroundBrush}}">
            <ContentPresenter ContentSource="Content" 
                              VerticalAlignment="Top"
                              HorizontalAlignment="Center"
                              Margin="{TemplateBinding Padding}"/>
        </ubcn:ButtonChrome>
    </ControlTemplate>

    <Style TargetType="{x:Type ubcn:NavigationItem}"
           x:Key="{x:Type ubcn:NavigationItem}">
        <Setter Property="Padding" Value="5,0,0,0"/>
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:NavigationItem}, ResourceId=DefaultNavigationitemTemplate}}" />
    </Style>

    <!--================================ScrollViewer Template And Style==============================================-->

    <ControlTemplate x:Key="ScrollerFlatRepeatButton" TargetType="{x:Type RepeatButton}">
        <ubcn:ButtonChrome CornerRadius="0" 
                          BorderThickness="1" 
                          RenderPressed="{TemplateBinding IsPressed}" 
                          RenderMouseOver="{TemplateBinding IsMouseOver}"
                          Content="{TemplateBinding Content}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          Background="{TemplateBinding Background}"
                          PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBackgroundBrush}}" 
                          PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBoderBrush}}"
                          MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBoderBrush}}"
                          MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"/>
    </ControlTemplate>
    <ControlTemplate x:Key="VerticalScrollBar_Thumb" 
                     TargetType="{x:Type Thumb}">
        <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}" 
                          BorderThickness="1" 
                          BorderBrush="{TemplateBinding BorderBrush}"
                          Background="{TemplateBinding Background}"
                          MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBackgroundBrush}}"
                          MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBorderBrush}}" 
                          PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBoderBrush}}"
                          RenderPressed="{TemplateBinding IsDragging}"
                          PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBackgroundBrush}}">
            <Image HorizontalAlignment="Center" 
                   VerticalAlignment="Center" 
                   Stretch="None"  
                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=HorizontalLines}}"/>
        </ubcn:ButtonChrome>
    </ControlTemplate>


    <ControlTemplate x:Key="HorizontalScrollBar_Thumb" TargetType="{x:Type Thumb}">
        <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}" 
                          BorderThickness="1" 
                          BorderBrush="{TemplateBinding BorderBrush}"
                          Background="{TemplateBinding Background}"
                          MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBackgroundBrush}}"
                          MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBorderBrush}}" 
                          PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBoderBrush}}"
                          RenderPressed="{TemplateBinding IsDragging}"
                          PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerPressedBackgroundBrush}}">
            <Image HorizontalAlignment="Center" 
                   VerticalAlignment="Center" 
                   Stretch="None"  
                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=VerticalLines}}"/>
        </ubcn:ButtonChrome>
    </ControlTemplate>

    <ControlTemplate x:Key="ScrollBar_PageButton" TargetType="{x:Type RepeatButton}">
        <ubcn:ButtonChrome BorderThickness="0" 
                          InnerBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                          RenderPressed="{TemplateBinding IsPressed}" 
                          PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PageButtonPressedBackgroundBrush}}"
                          PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"
                          InnerBorderThickness="0" 
                          Background="{TemplateBinding Background}"
                          BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"/>
    </ControlTemplate>

    <ControlTemplate x:Key="VerticalScrollBarTemplate" TargetType="{x:Type ScrollBar}">
        <Border Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"
                BorderThickness="0" 
                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedBorderBrush}}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="17"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="17"/>
                </Grid.RowDefinitions>
                <RepeatButton x:Name="PART_Uparrow" 
                              Width="15" 
                              Height="17" 
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBorderBrush}}"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                              Command="ScrollBar.LineUpCommand"
                              Template="{StaticResource ResourceKey=ScrollerFlatRepeatButton}">
                    <Image Margin="1,0,0,0"
                           Width="8"
                           Height="5"
                           HorizontalAlignment="Center" 
                           VerticalAlignment="Center" 
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LineUpArrow}}" 
                           Stretch="Fill"
                           Opacity=".8"/>
                </RepeatButton>
                <Track x:Name="PART_Track" 
                       Grid.Row="1" 
                       IsDirectionReversed="True">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Command="ScrollBar.PageUpCommand" 
                                      Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBackgroundBrush}}"
                                      Template="{StaticResource ResourceKey=ScrollBar_PageButton}" />
                    </Track.DecreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb x:Name="PART_Thumb" 
                               Template="{StaticResource ResourceKey=VerticalScrollBar_Thumb}" 
                               Width="15" 
                               MinHeight="6"
                               Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                               BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBorderBrush}}"/>
                    </Track.Thumb>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Command="ScrollBar.PageDownCommand" 
                                      Template="{StaticResource ResourceKey=ScrollBar_PageButton}" 
                                      Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBackgroundBrush}}"/>
                    </Track.IncreaseRepeatButton>
                </Track>
                <RepeatButton Command="ScrollBar.LineDownCommand" 
                              x:Name="PART_Downarrow" 
                              Grid.Row="2" 
                              Width="15" 
                              Height="17" 
                              Template="{StaticResource ResourceKey=ScrollerFlatRepeatButton}" 
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBorderBrush}}"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}">
                    <Image Margin="0.7,0,0,0"
                           Width="8"
                           Height="5"
                           HorizontalAlignment="Center" 
                           VerticalAlignment="Center" 
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LineDownArrow}}" 
                           Stretch="Fill"
                           Opacity=".8"/>
                </RepeatButton>
            </Grid>
        </Border>
    </ControlTemplate>

    <ControlTemplate x:Key="HorizontalScrollBarTemplate" 
                     TargetType="{x:Type ScrollBar}">
        <Border Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"
                BorderThickness="0" 
                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedBorderBrush}}">
            <Grid Width="{TemplateBinding ActualWidth}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="17" />
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="17" />
                </Grid.ColumnDefinitions>
                <RepeatButton Grid.Column="0" 
                              x:Name="PART_Leftarrow" 
                              Width="17" 
                              Template="{StaticResource ResourceKey=ScrollerFlatRepeatButton}"
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBorderBrush}}"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                              Command="ScrollBar.LineLeftCommand">
                    <Image HorizontalAlignment="Center" 
                           VerticalAlignment="Center" 
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LineLeftArrow}}" 
                           Stretch="Fill"
                           Width="5"
                           Height="8"
                           Opacity="0.8"/>
                </RepeatButton>
                <Track Name="PART_Track" 
                       Grid.Column="1" 
                       IsDirectionReversed="False">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Command="ScrollBar.PageLeftCommand" 
                                      Template="{StaticResource ResourceKey=ScrollBar_PageButton}"
                                      Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBackgroundBrush}}"/>
                    </Track.DecreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb x:Name="PART_Thumb"  
                               Template="{StaticResource ResourceKey=HorizontalScrollBar_Thumb}" 
                               Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                               BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBorderBrush}}"/>
                    </Track.Thumb>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Command="ScrollBar.PageRightCommand" 
                                      Template="{StaticResource ResourceKey=ScrollBar_PageButton}" 
                                      Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBackgroundBrush}}"/>
                    </Track.IncreaseRepeatButton>
                </Track>
                <RepeatButton Command="ScrollBar.LineRightCommand" 
                              x:Name="PART_Rightarrow" 
                              Grid.Column="2"  
                              Template="{StaticResource ResourceKey=ScrollerFlatRepeatButton}" 
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=ScrollerBorderBrush}}"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}">
                    <Image  HorizontalAlignment="Center" 
                            VerticalAlignment="Center" 
                            Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LineRightArrow}}" 
                            Stretch="Fill"
                            Width="5"
                           Height="8"
                            Opacity="0.8"/>
                </RepeatButton>
            </Grid>
        </Border>
    </ControlTemplate>

    <Style x:Key="DefaultScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Height" Value="16" />
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="MinWidth" Value="42"/>
                <Setter Property="Template" Value="{StaticResource ResourceKey=HorizontalScrollBarTemplate}"/>
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Width" Value="16"/>
                <Setter Property="MinHeight" Value="42"/>
                <Setter Property="Template" Value="{StaticResource ResourceKey=VerticalScrollBarTemplate}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <ControlTemplate x:Key="DeafultScrollViewerTemplate"  TargetType="{x:Type ScrollViewer}">
        <Grid x:Name="PART_Root">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <ScrollContentPresenter CanContentScroll="{TemplateBinding CanContentScroll}"
                            Content="{TemplateBinding Content}"/>
            <ScrollBar  Orientation="Vertical" 
                        Grid.Row="0" 
                        Grid.Column="1"
                        Minimum="0" 
                        Maximum="{TemplateBinding ScrollableHeight}"
                        Value="{TemplateBinding VerticalOffset}" 
                        ViewportSize="{TemplateBinding ViewportHeight}"
                        x:Name="PART_VerticalScrollBar"
                        Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                        Style="{StaticResource ResourceKey=DefaultScrollBarStyle}"/>
            <ScrollBar  Orientation="Horizontal" Grid.Row="1" Grid.Column="0"
                        Minimum="0" Maximum="{TemplateBinding ScrollableWidth}"
                        Value="{TemplateBinding HorizontalOffset}" 
                        ViewportSize="{TemplateBinding ViewportWidth}"
                        x:Name="PART_HorizontalScrollBar"
                        Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                        Style="{StaticResource ResourceKey=DefaultScrollBarStyle}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Visibility" Value="Collapsed" SourceName="PART_VerticalScrollBar">
                <Setter Property="MinWidth" Value="42.0"/>
            </Trigger>
            <Trigger Property="Visibility" Value="Collapsed" SourceName="PART_HorizontalScrollBar">
                <Setter Property="MinHeight" Value="42.0"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="ScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
        <Setter Property="IsDeferredScrollingEnabled" Value="False"/>
        <Setter Property="Template" Value="{StaticResource ResourceKey=DeafultScrollViewerTemplate}"/>
    </Style>

    <!--================================DropDownMenuItem Template and Style==============================================-->
    
    <!--========= TopLevelHeaderTemplate Template ========= -->
    <ControlTemplate x:Key="{x:Static ubcn:DropDownMenuItem.TopLevelHeaderTemplateKey}" 
                     TargetType="{x:Type ubcn:DropDownMenuItem}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <ContentPresenter ContentSource="Galleries"/>

            <Border x:Name="Border"
                    Grid.Row="1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="28" />
                        <ColumnDefinition />
                        <ColumnDefinition Width="10" />
                    </Grid.ColumnDefinitions>
                    <Image Source="{TemplateBinding Image}"
                           Height="17"
                           Width="17"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Margin="3,0"/>
                    <ContentPresenter Margin="6,3,6,3"
                                      ContentSource="Header"
                                      RecognizesAccessKey="True" 
                                      Grid.Column="1"
                                      x:Name="headerPresenter"/>
                    <Image Grid.Column="2" 
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RightArrow}}" 
                           Stretch="Fill" 
                           Width="3"
                           Height="6"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Margin="0,0,3,0"
                           Grid.Row="1"/>
                    <Popup x:Name="Popup"
                           Placement="Right"
                           IsOpen="{TemplateBinding IsSubmenuOpen}"
                           AllowsTransparency="True"
                           Focusable="False"
                           HorizontalOffset="-3.8">
                        <Border x:Name="SubmenuBorder"
                                SnapsToDevicePixels="True"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                                BorderThickness="1"
                                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownBorderBrush}}"
                                Margin="7"
                                Width="{TemplateBinding MaxDropDownWidth}">
                            <Border.RenderTransform>
                                <TranslateTransform />
                            </Border.RenderTransform>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Border  Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                                         Grid.RowSpan="2"
                                         Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownShadowEffect}}"/>
                                <ScrollViewer CanContentScroll="True"
                                              VerticalScrollBarVisibility="Auto"
                                              Style="{StaticResource ScrollViewerStyle}">
                                    <StackPanel IsItemsHost="True"
                                                KeyboardNavigation.DirectionalNavigation="Cycle" 
                                                x:Name="PART_DropDownMenuItemsHost"/>
                                </ScrollViewer>
                            </Grid>

                        </Border>
                    </Popup>
                </Grid>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation"
                     Value="true">
                <Setter TargetName="Popup"
                        Property="PopupAnimation"
                        Value="None" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="False" SourceName="Border"/>
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background"
                            TargetName="Border"
                            Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" SourceName="Border" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background"
                        TargetName="Border"
                       Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background"
                        TargetName="Border"
                       Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                     Value="False">
                <Setter Property="TextBlock.Foreground"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}"
                        TargetName="headerPresenter"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    <!--========= TopLevelItemTemplate Template ========= -->
    
    <ControlTemplate x:Key="{x:Static ubcn:DropDownMenuItem.TopLevelItemTemplateKey}"
                     TargetType="{x:Type ubcn:DropDownMenuItem}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <ContentPresenter ContentSource="Galleries"/>
            <Border x:Name="Border"
                    Grid.Row="1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="28" />
                        <ColumnDefinition  />
                    </Grid.ColumnDefinitions>
                    <Image Source="{TemplateBinding Image}"
                           Height="17"
                           Width="17"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Center"
                           Margin="3,0"/>
                    <ContentPresenter Margin="6,3,6,3"
                                  ContentSource="Header"
                                  RecognizesAccessKey="True" 
                                  VerticalAlignment="Center"
                                  Grid.Column="1"
                                  x:Name="HeaderHost"/>
                </Grid>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Header" Value="{x:Null}">
                <Setter Property="Visibility" Value="Collapsed" TargetName="Border"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="False" SourceName="Border"/>
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background"
                        TargetName="Border"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" SourceName="Border" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background"
                        TargetName="Border"
                       Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background"
                        TargetName="Border"
                       Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                     Value="False">
                <Setter Property="TextBlock.Foreground"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}"
                        TargetName="HeaderHost"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    <!--========= SubmenuTemplate Template ========= -->
    
    <ControlTemplate x:Key="{x:Static ubcn:DropDownMenuItem.SubmenuHeaderTemplateKey}"
                 TargetType="{x:Type ubcn:DropDownMenuItem}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <ContentPresenter ContentSource="Galleries"/>

            <Border x:Name="Border"
                    Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                    Grid.Row="1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="28" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto"
                                      SharedSizeGroup="Shortcut" />
                        <ColumnDefinition Width="10" />
                    </Grid.ColumnDefinitions>
                    <Image Source="{TemplateBinding Image}"
                           Height="17"
                           Width="17"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Margin="3,0"/>
                    <ContentPresenter x:Name="HeaderHost"
                                      Grid.Column="1"
                                      ContentSource="Header"
                                      RecognizesAccessKey="True" 
                                      VerticalAlignment="Center"
                                      Margin="6,3,6,3"/>
                    <TextBlock x:Name="InputGestureText"
                               Grid.Column="2"
                               Text="{TemplateBinding InputGestureText}"
                               Margin="5,2,2,2"
                               DockPanel.Dock="Right"/>
                    <Image Grid.Column="3" 
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RightArrow}}" 
                           Stretch="Fill" 
                           Width="3"
                           Height="6"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Margin="0,0,3,0"/>
                    <Popup x:Name="Popup"
                           Placement="Right"
                           IsOpen="{TemplateBinding IsSubmenuOpen}"
                           AllowsTransparency="True"
                           Focusable="False"
                           HorizontalOffset="-3.8">
                        <Border x:Name="SubmenuBorder"
                                SnapsToDevicePixels="True"
                                BorderThickness="1"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownBorderBrush}}"
                                Margin="7"
                                Width="{TemplateBinding MaxDropDownWidth}">
                            <Border.RenderTransform>
                                <TranslateTransform />
                            </Border.RenderTransform>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Border  Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                                         Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownShadowEffect}}"
                                         Grid.RowSpan="2"/>
                                <ScrollViewer CanContentScroll="True"
                                              VerticalScrollBarVisibility="Auto"
                                              Style="{StaticResource ScrollViewerStyle}">
                                    <StackPanel IsItemsHost="True"
                                            KeyboardNavigation.DirectionalNavigation="Cycle" 
                                            x:Name="PART_DropDownMenuItemsHost"/>
                                </ScrollViewer>
                            </Grid>
                        </Border>
                    </Popup>
                </Grid>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="False" SourceName="Border"/>
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background"
                        TargetName="Border"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" SourceName="Border" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background"
                        TargetName="Border"
                       Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background"
                        TargetName="Border"
                       Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                     Value="false">
                <Setter Property="TextBlock.Foreground"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}"
                        TargetName="HeaderHost"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--========= SubmenuItem Template ========= -->
    
    <ControlTemplate x:Key="{x:Static ubcn:DropDownMenuItem.SubmenuItemTemplateKey}"
                     TargetType="{x:Type ubcn:DropDownMenuItem}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <ContentPresenter ContentSource="Galleries"
                              />
            <Border x:Name="Border" 
                    Grid.Row="1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="28"/>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Image Source="{TemplateBinding Image}"
                           Height="17"
                           Width="17"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Margin="3,0"/>
                    <ContentPresenter x:Name="HeaderHost"
                                      Grid.Column="1"
                                      ContentSource="Header"
                                      RecognizesAccessKey="True"
                                      VerticalAlignment="Center"
                                      Margin="6,3,6,3"/>
                    <TextBlock x:Name="InputGestureText"
                               Grid.Column="2"
                               Text="{TemplateBinding InputGestureText}"
                               Margin="5,2,0,2"
                               DockPanel.Dock="Right"/>
                </Grid>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="ButtonBase.Command"
                     Value="{x:Null}" />
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="False" SourceName="Border"/>
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background"
                        TargetName="Border"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" SourceName="Border" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background"
                        TargetName="Border"
                       Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background"
                        TargetName="Border"
                       Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                      Value="false">
                <Setter Property="TextBlock.Foreground"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}"
                        TargetName="HeaderHost"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--========= Default Style ========= -->
    
    <Style x:Key="{x:Type ubcn:DropDownMenuItem}" TargetType="{x:Type ubcn:DropDownMenuItem}">
        <Setter Property="MinHeight" Value="25"/>
        <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
        <Style.Triggers>
            <Trigger Property="Role"
                    Value="TopLevelHeader">
                <Setter Property="Template"
                         Value="{StaticResource {x:Static ubcn:DropDownMenuItem.TopLevelHeaderTemplateKey}}" />
                <Setter Property="Grid.IsSharedSizeScope"
                        Value="True" />
            </Trigger>
            <Trigger Property="Role"
                     Value="TopLevelItem">
                <Setter Property="Template"
                        Value="{StaticResource {x:Static ubcn:DropDownMenuItem.TopLevelItemTemplateKey}}" />
            </Trigger>
            <Trigger Property="Role"
                    Value="SubmenuHeader">
                <Setter Property="Template"
                        Value="{StaticResource {x:Static ubcn:DropDownMenuItem.SubmenuHeaderTemplateKey}}" />
            </Trigger>
            <Trigger Property="Role"
                     Value="SubmenuItem">
                <Setter Property="Template"
                        Value="{StaticResource {x:Static ubcn:DropDownMenuItem.SubmenuItemTemplateKey}}" />
            </Trigger>
            <Trigger Property="Header" Value="{x:Null}">
                <Setter Property="MinHeight" Value="0"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect  DesaturationFactor="0.0"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>


    <!--================================ControlTemplates and Styles for Window buttons==============================================-->

    <!--Minimize button template-->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultCaptioButtonTemplate}"
                     TargetType="{x:Type Button}">
        <ubcn:ButtonChrome      InnerBorderCornerRadius="0" 
                               InnerBorderThickness="0"  
                               BorderThickness="0"
                               BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                               Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"  
                               RenderMouseOver="{TemplateBinding IsMouseOver}"
                               RenderPressed="{TemplateBinding IsPressed}"
                               HorizontalContentAlignment="Center"
                               VerticalContentAlignment="Center">
            <Rectangle Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultImageBrush}}" 
                        RenderOptions.BitmapScalingMode="Linear" 
                        HorizontalAlignment="Center"
                        Margin="0, 5.5, 0, 0"  
                        Height="2" 
                        Width="9"
                       x:Name="MinimizeButton_Content"/>
        </ubcn:ButtonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Fill" 
                        TargetName="MinimizeButton_Content" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
            </Trigger>
            <Trigger Property="IsPressed" 
                         Value="True">
                <Setter Property="Fill" 
                        TargetName="MinimizeButton_Content" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--Maximize button template-->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly=ubcn:XWindow, ResourceId=MaximizeButtonTemplate}"
                     TargetType="{x:Type Button}">
        <ubcn:ButtonChrome      InnerBorderCornerRadius="0" 
                                      InnerBorderThickness="0"  
                                      BorderThickness="0"
                                      BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                                      Background="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}"  
                                      RenderMouseOver="{TemplateBinding IsMouseOver}"
                                      RenderPressed="{TemplateBinding IsPressed}"
                                      HorizontalContentAlignment="Center"
                                      VerticalContentAlignment="Center">
            <Grid RenderOptions.EdgeMode="Aliased">
                <Path Data="M0,0L9,0 9,9 0,9 0,0z" 
                      StrokeThickness="1" 
                      Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultImageBrush}}"
                      StrokeStartLineCap="Flat" 
                      StrokeEndLineCap="Flat" 
                      Stretch="None" 
                      x:Name="MaximizeButton_Path1"/>
                <Path Data="M0,1L9,1" 
                      StrokeThickness="2"
                      Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultImageBrush}}"
                      StrokeStartLineCap="Flat" 
                      StrokeEndLineCap="Flat" 
                      Stretch="None" 
                      x:Name="MaximizeButton_Path2"/>
            </Grid>
        </ubcn:ButtonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Stroke" TargetName="MaximizeButton_Path1" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
                <Setter Property="Stroke" TargetName="MaximizeButton_Path2" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Stroke" TargetName="MaximizeButton_Path1" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
                <Setter Property="Stroke" TargetName="MaximizeButton_Path2" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--Restore button template-->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=RestoreButtonTemplate}"
                     TargetType="{x:Type Button}">
        <ubcn:ButtonChrome      InnerBorderCornerRadius="0" 
                                InnerBorderThickness="0"  
                                BorderThickness="0"
                                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                                Background="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}"  
                                RenderMouseOver="{TemplateBinding IsMouseOver}"
                                RenderPressed="{TemplateBinding IsPressed}"
                                HorizontalContentAlignment="Center"
                                VerticalContentAlignment="Center">
            <Grid RenderOptions.EdgeMode="Aliased">
                <Path Data="M0,3L6,3 6,8 0,8 0,4z  M3,2 L3,0L9,0L9,5L7,5" 
                      StrokeThickness="1"
                      Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultImageBrush}}" 
                      StrokeStartLineCap="Flat"
                      StrokeEndLineCap="Flat" 
                      x:Name="RestoreButton_Path1"/>
                <Path Data="M0,4L6,4 M3,1L9,1" 
                      ClipToBounds="True" 
                      StrokeThickness="2"
                      Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultImageBrush}}"
                      StrokeStartLineCap="Flat"
                      StrokeEndLineCap="Flat"
                      x:Name="RestoreButton_Path2"/>
            </Grid>

        </ubcn:ButtonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Stroke" TargetName="RestoreButton_Path1" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
                <Setter Property="Stroke" TargetName="RestoreButton_Path2" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Stroke" TargetName="RestoreButton_Path1" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
                <Setter Property="Stroke" TargetName="RestoreButton_Path2" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--Close button template-->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=CloseButtonTemplate}"
                     TargetType="{x:Type Button}">
        <ubcn:ButtonChrome   InnerBorderCornerRadius="0" 
                            InnerBorderThickness="0"  
                            BorderThickness="0"
                            BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" 
                            Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"  
                            RenderMouseOver="{TemplateBinding IsMouseOver}"
                            RenderPressed="{TemplateBinding IsPressed}"
                            HorizontalContentAlignment="Center"
                            VerticalContentAlignment="Center">
            <Image  Stretch="None"
                    x:Name="CloseButton_Image"
                    Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=NormalStateImage}}"/>
        </ubcn:ButtonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverStateImage}}" 
                        TargetName="CloseButton_Image"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedStateImage}}"  
                        TargetName="CloseButton_Image"/>
            </Trigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--Minimize button style-->
    <Style TargetType="{x:Type Button}" 
           x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultCaptioButtonStyle}">
        <Setter Property="Width" Value="28"/>
        <Setter Property="Height" Value="25"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="RenderOptions.EdgeMode" Value="Aliased"/>
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultCaptioButtonTemplate}}"/>
    </Style>

    <!--Maximize button style-->
    <Style BasedOn="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultCaptioButtonStyle}}" 
           TargetType="{x:Type Button}" 
           x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=MaximizeButtonStyle}">
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=MaximizeButtonTemplate}}"/>
    </Style>

    <!--Restore button style-->
    <Style BasedOn="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultCaptioButtonStyle}}" 
           TargetType="{x:Type Button}" 
           x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=RestoreButtonStyle}">
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly=ubcn:XWindow, ResourceId=RestoreButtonTemplate}}"/>
    </Style>

    <!--Close button style-->
    <Style BasedOn="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultCaptioButtonStyle}}" 
           TargetType="{x:Type Button}" 
           x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=CloseButtonStyle}">
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=CloseButtonTemplate}}"/>
    </Style>

    <!--================================XWindow Template And Style==============================================-->

    <Thickness x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBorderThickness}">1</Thickness>

    <!--========= XWindow Template ========= -->
    
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultXWindowTemplate}"
                     TargetType="{x:Type ubcn:XWindow}">
        <Border BorderThickness="{TemplateBinding BorderThickness}" 
                CornerRadius="0" 
                x:Name="PART_OuterBorder"
                Grid.IsSharedSizeScope="True" 
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}" 
                IsHitTestVisible="True" 
                Margin="0"
                >
            <Grid x:Name="PART_RootPanel" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="29" x:Name="titleRow"/>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Column="1"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Text="{TemplateBinding Title}"
                           x:Name="PART_TitleText"
                           TextTrimming="CharacterEllipsis"
                           Grid.IsSharedSizeScope="True"
                           TextAlignment="Left"/>
                <StackPanel x:Name="ButtonsPanel" 
                            Orientation="Horizontal" 
                            Grid.Column="2" 
                            HorizontalAlignment="Right" 
                            VerticalAlignment="Center"
                            Panel.ZIndex="2">
                    <Button x:Name="MinimizeButton" 
                                     Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultCaptioButtonStyle}}"
                                     Command="{x:Static ubcn:XWindow.MinimizeCommand}"  
                                     Visibility="{Binding Path=IsMinimizeButtonEnabled, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource ResourceKey=BooleanConverter}}"/>
                    <Button x:Name="MaximizeButton" 
                                     Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=MaximizeButtonStyle}}"
                                     Command="{x:Static ubcn:XWindow.MaximizeCommand}"  
                                     Visibility="{Binding Path=IsMinimizeButtonEnabled, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource ResourceKey=BooleanConverter}}"/>
                    <Button x:Name="CloseButton" 
                                     Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=CloseButtonStyle}}"
                                     Command="{x:Static ubcn:XWindow.CloseCommand}"  
                                     Visibility="{Binding Path=IsCloseButtonEnabled, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource ResourceKey=BooleanConverter}}"/>
                </StackPanel>
                <Image  x:Name="PART_Icon" 
                        HorizontalAlignment="Left" 
                        VerticalAlignment="Center"  
                        Source="{TemplateBinding Icon}" 
                        Width="17" 
                        Height="17" 
                        Stretch="Fill" 
                        RenderOptions.BitmapScalingMode="HighQuality"
                        Margin="10, 0, 0, 0"/>
                <AdornerDecorator  Grid.Row="1"
                                   Grid.ColumnSpan="3"
                                   x:Name="PART_ContentAdorner"
                                   Panel.ZIndex="1">
                    <ContentPresenter Content="{TemplateBinding Content}"/>

                </AdornerDecorator>
                <Border Grid.Row="2" 
                        Background="{TemplateBinding FooterBackground}"
                        Grid.ColumnSpan="3"
                        x:Name="XWindow_FooterBorder">
                    <ContentPresenter ContentSource="{TemplateBinding Footer}"
                                      x:Name="PART_Footer"/>
                </Border>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="WindowState" Value="Maximized">
                <Setter Property="Style" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=RestoreButtonStyle}}"
                        TargetName="MaximizeButton"/>
                <Setter Property="Margin" Value="{Binding Path=MaximizeMargin, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}" TargetName="PART_OuterBorder"/>
            </Trigger>
            <Trigger Property="Footer" Value="{x:Null}">
                <Setter Property="Visibility" Value="Collapsed" TargetName="XWindow_FooterBorder"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--========= XWindow Style ========= -->
    
    <Style x:Key="{x:Type ubcn:XWindow}" TargetType="{x:Type ubcn:XWindow}">
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBackgroundBrush}}"/>
        <Setter Property="BorderThickness" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBorderThickness}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}"/>
        <Setter Property="FooterBackground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=FooterBackground}}"/>
        <Setter Property="Template" Value="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:XWindow}, ResourceId=DefaultXWindowTemplate}}"/>
    </Style>

    <!--========= Custom Button Style ========= -->
    
    <Style TargetType="{x:Type Button}"
           x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:NavigationHelper}, ResourceId=CustomButtonStyle}">
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedBorderBrush}}"/>
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}"
                                       RenderPressed="{TemplateBinding IsPressed}"
                                       BorderThickness="{TemplateBinding BorderThickness}"
                                       CornerRadius="{Binding Path=(ubcn:NavigationHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                       Content="{TemplateBinding Content}"
                                       Background="{TemplateBinding Background}"
                                       BorderBrush="{TemplateBinding BorderBrush}"
                                       MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedMenuBackgroundBrush}}"
                                       PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}"
                                       HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                       VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect DesaturationFactor="0.0" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--========= CustomRepeatButton Style ========= -->
    
    <Style TargetType="{x:Type RepeatButton}"
           x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:NavigationHelper}, ResourceId=CustomRepeatButtonStyle}">
        <Setter Property="BorderThickness" Value="1"/>

        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DisabledBackgroundBrush}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}"
                                       RenderPressed="{TemplateBinding IsPressed}"
                                       BorderThickness="{TemplateBinding BorderThickness}"
                                       CornerRadius="{Binding Path=(ubcn:NavigationHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                       Content="{TemplateBinding Content}"
                                       Background="{TemplateBinding Background}"
                                       BorderBrush="{TemplateBinding BorderBrush}"
                                       MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedMenuBackgroundBrush}}"
                                       PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}"
                                       HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                       VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect DesaturationFactor="0.0" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--========= ControlTemplate for NumerticUpDown ========= -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:NumericUpDown}, ResourceId=DefaultNumericUpDownTemplate}"
                     TargetType="{x:Type ubcn:NumericUpDown}">
        <Border BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                Background="{TemplateBinding Background}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBox Grid.RowSpan="2" 
                         BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}"
                         Background="{TemplateBinding Background}"
                         BorderThickness="0"
                         x:Name="PART_TextBox"
                         Focusable="True" 
                         HorizontalScrollBarVisibility="Disabled"
                         VerticalScrollBarVisibility="Disabled">
                    <TextBox.Text>
                        <Binding Path="Value"
                                 RelativeSource="{RelativeSource Mode=TemplatedParent}"
                                 ValidatesOnDataErrors="True" 
                                 ValidatesOnExceptions="True"
                                 Mode="TwoWay"
                                 NotifyOnSourceUpdated="True"
                                 NotifyOnTargetUpdated="True"
                                 NotifyOnValidationError="True"
                                 UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <ExceptionValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                    <TextBox.Style>
                        <Style TargetType="{x:Type TextBox}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type TextBoxBase}">
                                        <Border Name="Border"
                                                CornerRadius="0" 
                                                Padding="2,0,2,0"
                                                Background="{TemplateBinding Background}"
                                                BorderBrush="{TemplateBinding BorderBrush}">
                                            <ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsEnabled" Value="False">
                                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DisabledBackgroundBrush}}"/>
                                                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DisabledBackgroundBrush}}"/>
                                                <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DisabledForegroundBrush}}"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </TextBox.Style>
                </TextBox>
                <RepeatButton Grid.Column="1"
                              ubcn:NavigationHelper.EnableCustomStyle="True"
                              ubcn:NavigationHelper.CornerRadius="0"
                              Width="17"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DisabledBackgroundBrush}}"
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GrayBrush}}"
                              x:Name="upButton"
                              Command="{Binding Path=IncrementCommand, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                              CommandParameter="Up"
                              Focusable="False"
                              Delay="{TemplateBinding Delay}">
                    <Image HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Height="2.5"
                           Width="5"
                           Stretch="Fill"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=UpImage}}"
                           x:Name="upImage"/>
                </RepeatButton>
                <RepeatButton Grid.Column="1"
                              Grid.Row="1"
                              ubcn:NavigationHelper.EnableCustomStyle="True"
                              ubcn:NavigationHelper.CornerRadius="0"
                              Width="17"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DisabledBackgroundBrush}}"
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GrayBrush}}"
                              x:Name="downButton"
                              Command="{Binding Path=DecrementCommand, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                              CommandParameter="Down"
                              Focusable="False"
                              Delay="{TemplateBinding Delay}">
                    <Image HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Height="2.5"
                           Width="5"
                           Stretch="Fill"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DownImage}}"
                           x:Name="downImage"/>
                </RepeatButton>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=(Validation.HasError), ElementName=PART_TextBox}" Value="True">
                <Setter Property="IsEnabled" Value="False" TargetName="downButton" />
                <Setter Property="IsEnabled" Value="False" TargetName="upButton" />
            </DataTrigger>
            <Trigger Property="IsEnabled" Value="False" SourceName="upButton">
                <Setter Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DisabledUpImage}}" 
                        TargetName="upImage"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False" SourceName="downButton">
                <Setter Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DisableDownImage}}" 
                        TargetName="downImage"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--========= Style for NumerticUpDown ========= -->
    
    <Style TargetType="{x:Type ubcn:NumericUpDown}"
           x:Key="{x:Type ubcn:NumericUpDown}">
        <Setter Property="Height" Value="20"/>
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:NumericUpDown}, ResourceId=DefaultNumericUpDownTemplate}}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Background" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GrayBrush}}" />
    </Style>

    <!--========= NavigationSettingsWindow content ========= -->
    
    <Grid x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcn:OutlookBar}, ResourceId=NavigationSettingsWindowContent}"
          Margin="0,5">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="100" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid Grid.ColumnSpan="2"
              Margin="5, 3, 5, 3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Text="Maximum visible items count:"
                       Margin="0, 0, 5, 0"
                       HorizontalAlignment="Left"/>

            <ubcn:NumericUpDown MinValue="1" 
                                Grid.Column="1"
                                Width="85"
                                Margin="3,0"
                                HorizontalAlignment="Left"/>

            <CheckBox Content="Compact navigation" 
                      Margin="0,7,0,3"
                      Grid.Row="1"
                      HorizontalAlignment="Left"/>
        </Grid>
        <Rectangle Height="1" 
                   Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GrayBrush}}"
                   Grid.Row="1"
                   Grid.ColumnSpan="2"
                   VerticalAlignment="Top"
                   Margin="5, 7, 5, 0"/>
        <ListBox Grid.Row="1"
                 Margin="5, 17, 5, 10"
                 DisplayMemberPath="Title"
                 x:Name="listBox"
                 BorderThickness="1"
                 BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GrayBrush}}">
            <ListBox.Template>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            >
                        <ScrollViewer HorizontalScrollBarVisibility="Disabled"
                                  VerticalScrollBarVisibility="Auto"
                                  Style="{StaticResource ResourceKey=ScrollViewerStyle}">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </ListBox.Template>
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                <ubcn:ButtonChrome RenderMouseOver="{TemplateBinding IsMouseOver}" 
                                                   RenderPressed="{TemplateBinding IsSelected}">
                                    <ContentPresenter ContentSource="Content" 
                                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                </ubcn:ButtonChrome>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
        <StackPanel Grid.Column="1"
                    Margin="5, 17, 5, 5"
                    Grid.Row="1">
            <Button Content="Up"
                    ubcn:NavigationHelper.EnableCustomStyle="True" 
                    ubcn:NavigationHelper.CornerRadius="0"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Height="22"
                    Margin="0,5"
                    Name="upButton"/>
            <Button Content="Down"  
                    ubcn:NavigationHelper.EnableCustomStyle="True" 
                    ubcn:NavigationHelper.CornerRadius="0"
                    Height="22"
                    Margin="0,5"
                    Name="downButton"/>
        </StackPanel>
        <Rectangle Height="1" 
                   Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GrayBrush}}"
                   Grid.Row="1"
                   Grid.ColumnSpan="2"
                   VerticalAlignment="Bottom"
                   Margin="5, 10, 5, 0"/>
        <StackPanel Grid.ColumnSpan="2"
                    Grid.Row="2" 
                    HorizontalAlignment="Right"
                    Orientation="Horizontal"
                    Margin="5,10,5,5">
            <Button Content="Default"
                    ubcn:NavigationHelper.EnableCustomStyle="True" 
                    ubcn:NavigationHelper.CornerRadius="0"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Height="22"
                    Margin="5,0"
                    Width="75"/>
            <Button Content="OK"
                    ubcn:NavigationHelper.EnableCustomStyle="True" 
                    ubcn:NavigationHelper.CornerRadius="0"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Height="22"
                    Margin="5,0"
                    Width="75"/>
            <Button Content="Cancel"
                    ubcn:NavigationHelper.EnableCustomStyle="True" 
                    ubcn:NavigationHelper.CornerRadius="0"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Height="22"
                    Margin="5,0"
                    Width="75"
                    Command="{x:Static ubcn:XWindow.CloseCommand}"/>
        </StackPanel>
    </Grid>
</ResourceDictionary>
    
    